package com.wxq.weitool;

import java.util.Objects;

import com.wxq.weitool.tuple.Tuple3;
import com.wxq.weitool.tuple.Tuples;

public class Files {
    /**
	 * 
	 */
	
	private static final String COMMA_SEPERATOR = "\\.";
	public static final  String PATH_SEPERATOR = "/";
/**将带路径的文件名分拆成三部分  目录 、文件名、扩展名
 * @return  返回 目录、文件名、扩展名
 */

    public static Tuple3<String,String,String> splitFileName(String pathName){
        Objects.requireNonNull(pathName);
        int lastIndexOf = pathName.lastIndexOf(PATH_SEPERATOR);
        String dir="";
        if (lastIndexOf>0){
            dir=pathName.substring(0,lastIndexOf);

        }
        final String nameAndExt = pathName.substring(lastIndexOf + 1);
        String[] split = nameAndExt.split(COMMA_SEPERATOR);
        
        return Tuples.of(dir,split[0],split[1]);
    }
}
